package com.test;

/*
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Example04 {
    public static void main(String[] args) {
        Pattern p1 = Pattern.compile("a*b");        //根据参数指定的正则表达式创建模式
        Matcher m1 = p1.matcher("aaaaab");    //获取目标字符串的匹配器
        Matcher m2 = p1.matcher("aaabbb");    //获取目标字符串的匹配器
        System.out.println(m1.matches());           //执行匹配器
        System.out.println(m2.matches());           //执行匹配器
        Pattern p2 = Pattern.compile("[/]+");
        String[] str = p2.split("张三//李四/王五//赵六/钱七"); //按模式分割字符串
        for(String s : str){
            System.out.print(s+"\t");
        }
    }
}


 */


/*
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Example04 {
    public static void main(String[] args) {
        Pattern p = Pattern.compile("\\d+");
        Matcher m = p.matcher("22bb23");
        System.out.println("字符串是否匹配:" + m.matches());
        Matcher m2 = p.matcher("2223");
        System.out.println("字符串2223与模式p是否匹配:" + m2.matches());
        System.out.println("字符串22bb23与模式p的匹配结果:" + m.lookingAt());
        Matcher m3 = p.matcher("aa2223");
        System.out.println("字符串aa2223与模式p的匹配结果:" + m3.lookingAt());
        System.out.println("字符串22bb23与模式p是否存在下一个匹配结果:" +
                m.find());
        m3.find();//返回true
        System.out.println("字符串aa2223与模式p是否存在在下一个匹配结果：" +
                m3.find());
        Matcher m4 = p.matcher("aabb");
        System.out.println("字符串aabb与模式p是否存在下一个匹配结果：" +
                m4.find());
        Matcher m1 = p.matcher("aaa2223bb");
        m1.find();//匹配2223
        System.out.println("模式p与字符串aaa2223bb的匹配的起始索引:" +
                m1.start());
        System.out.println("模式p与字符串aaa2223bb的最后一个字符匹配后的偏移量" +
                m1.end());
        System.out.println("模式p与字符串aaa2223bb的匹配到的子字符串:" +
                m1.group());
        Pattern p2 = Pattern.compile("[/]+");
        Matcher m5 = p2.matcher("张三/李四//王五///赵六");
        System.out.println("将字符串张三/李四//王五///赵六中的/全部替换为|:" +
                m5.replaceAll("|"));
        System.out.println("将字符串张三/李四//王五///赵六中的首个/替换为|:" +
                m5.replaceFirst("|"));
    }
}


 */

public class Example04 {
    public static void main(String[] args) {
        String str = "A1B22DDS34DSJ9D".replaceAll("\\d+","_");
        System.out.println("字符串替换后为："+str);
        boolean te = "321123as1".matches("\\d+");
        System.out.println("字符串是否匹配："+te);
        String[] s="SDS45d4DD4dDS88D".split("\\d+");
        System.out.print("字符串拆分后为：");
        for(int i=0;i<s.length;i++){
            System.out.print(s[i]+"  ");
        }
    }
}
